//
//  YSSellerReplyView.m
//  Yueshi
//
//  Created by yueshi－mac1 on 16/1/20.
//  Copyright © 2016年 悦食中国. All rights reserved.
//

#import "YSSellerReplyView.h"
#define kSellerTipsFont 14
#define kSellerReplyContentFont 13

@interface YSSellerReplyView()
@property (strong, nonatomic) UILabel *sellerLabel;
@property (strong, nonatomic) UILabel *replyContentLabel;
@property (strong, nonatomic) UIImageView *replyContentView;
@end

@implementation YSSellerReplyView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *sellerLabel = [[UILabel alloc] init];
        sellerLabel.font = SYS_FONT(kSellerTipsFont);
        sellerLabel.textColor = ThemeColor;
        NSString *sellerText = @"商家回复";
        sellerLabel.text = sellerText;
        CGSize size = [sellerText sizeWithFont:SYS_FONT(kSellerTipsFont)];
        sellerLabel.frame = CGRectMake(YSPublicXInset, 10, size.width, size.height);
        _sellerLabel = sellerLabel;
        [self addSubview:sellerLabel];
        
        UILabel *replyContentLabel = [[UILabel alloc] init];
        replyContentLabel.font = SYS_FONT(kSellerReplyContentFont);
        replyContentLabel.textColor = HEXColor(@"#9e9e9e");
        replyContentLabel.numberOfLines = 0;
        _replyContentLabel = replyContentLabel;
        
        UIImageView *replyContentView = [[UIImageView alloc] init];
        UIImage *image = [UIImage imageNamed:@"bg_seller_reply"];
        replyContentView.image = image;
        _replyContentView = replyContentView;
        
        [self addSubview:replyContentView];
        [self addSubview:replyContentLabel];
        
    }
    
    self.bounds = CGRectMake(0, 0, 0, 0);
    return self;
}

- (void) setReplyContent:(NSString *)content{
    CGSize contentSize = [content sizeWithFont:_replyContentLabel.font constrainedToSize:CGSizeMake(SCREENW-YSPublicXInset*2 - _sellerLabel.width - 16 - 10, MAXFLOAT)];
    _replyContentView.frame = CGRectMake(CGRectGetMaxX(_sellerLabel.frame), 0, SCREENW-YSPublicXInset*2 - _sellerLabel.width, contentSize.height + 10 + 7);
    
    _replyContentLabel.frame = CGRectMake(CGRectGetMaxX(_sellerLabel.frame) + 18, 10, contentSize.width, contentSize.height);
    _replyContentLabel.text = content;
}

+ (CGFloat)getHeightWithContent:(NSString *)content{
    CGSize sellerSize = [@"商家回复" sizeWithFont:SYS_FONT(kSellerTipsFont)];
    CGSize contentSize = [content sizeWithFont:SYS_FONT(kSellerReplyContentFont) constrainedToSize:CGSizeMake(SCREENW-YSPublicXInset*2 - sellerSize.width - 16 - 10, MAXFLOAT)];
    return contentSize.height + 10 + 7;
}

@end
